const path = require("path");
const {rspack, RspackCLI} = require('@rspack/cli');
module.exports = {
  mode: "development",
  entry: {
    main: "./example/index.jsx",
    home: "./example/home.jsx",
    detail: "./example/detail.jsx",
    form: "./example/form.jsx",
    login: "./example/login.jsx",
  },
  // plugins:[
  //   new RspackCLI.
  // ],
  output: {
    library: {
      type: "umd",
      umdNamedDefine: true,
    },
    publicPath: "/",
  },

  externals: {
    react: "react",
    "react-dom": "react-dom",
    "react-dom/server": "react-dom/server",
    moment: "moment",
    antd: "antd",
    // lodash: 'lodash',
  },
  resolve: {
    alias: {
      "@web-design/ui": path.resolve(__dirname, "package/ui/src"),
      "@web-design/login": path.resolve(__dirname, "package/login/src"),
      "@web-design/micro-app": path.resolve(__dirname, "package/micro-app/src"),
      "@web-design/layout": path.resolve(__dirname, "package/layout/src"),
    },
  },
  devServer: {
    hot: true,
    historyApiFallback: true,

    allowedHosts: [".csb.app"],
  },
  module: {
    rules: [
      {
        test: /.less$/,
        use: [
          {
            loader: "less-loader",
            options: {
              lessOptions: {
                javascriptEnabled: true,
              },
            },
          },
        ],
        type: "css",
      },
    ],
    parser: {
      asset: {
        dataUrlCondition: {
          maxSize: 1,
        },
      },
    },
  },
  builtins: {
    html: [
      {
        template: "./index.html",
        inject: false,
      },
    ],
    define: {
      "process.env.NODE_ENV": "'development'",
    },
    progress: {},
    react: {
      development: true,
      refresh: true,
    },
  },
};
